<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>koTime</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/layui/css/global.css}" media="all">
    <style>
        .site-doc-icon li{width: 222px;}
        .site-doc-icon li .layui-anim{width: 80px; height: 80px; line-height: 80px; margin: 0 auto 10px; text-align: center; background-color: #009688; cursor: pointer; color: #fff; border-radius: 50%;}
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>koTime调用链路追踪</legend>
</fieldset>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <li class="layui-this">总览</li>
        <li>接口列表</li>
        <li>联系我</li>
    </ul>
    <div class="layui-tab-content" style="height: 100px;">
        <div class="layui-tab-item layui-show">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                <legend>接口统计</legend>
            </fieldset>
            <ul class="site-doc-icon site-doc-anim">
                <li>
                    <div class="layui-anim" data-anim="layui-anim-up" th:text="${system.totalNum}"></div>
                    <div class="code">接口数</div>
                </li>
                <li>
                    <div class="layui-anim" style=" <#if system.delayNum gt 0 >background-color: #da3f0b;</#if>" data-anim="layui-anim-upbit" th:text="${system.delayNum}"></div>
                    <div class="code">延迟响应数</div>
                </li>
                <li>
                    <div class="layui-anim" data-anim="layui-anim-scale" th:text="${system.normalNum}"></div>
                    <div class="code">正常响应数</div>
                </li>
            </ul>
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                <legend>响应统计</legend>
            </fieldset>
            <ul class="site-doc-icon site-doc-anim">
                <li>
                    <div th:if="${system.avgRunTime ge config.timeThreshold}" class="layui-anim" style="background-color: #da3f0b;" data-anim="layui-anim-up" th:text="${system.avgRunTime}"></div>
                    <div th:if="${system.avgRunTime lt config.timeThreshold}" class="layui-anim"  data-anim="layui-anim-up" th:text="${system.avgRunTime}"></div>

                    <div class="code">平均响应（ms）</div>
                </li>
                <li>
                    <div th:if="${system.maxRunTime ge config.timeThreshold}" class="layui-anim" style="background-color: #da3f0b;" data-anim="layui-anim-up" th:text="${system.maxRunTime}"></div>
                    <div th:if="${system.maxRunTime lt config.timeThreshold}" class="layui-anim"  data-anim="layui-anim-up" th:text="${system.maxRunTime}"></div>

                    <div class="code">最大响应（ms）</div>
                </li>
                <li>
                    <div th:if="${system.minRunTime ge config.timeThreshold}" class="layui-anim" style="background-color: #da3f0b;" data-anim="layui-anim-up" th:text="${system.minRunTime}"></div>
                    <div th:if="${system.minRunTime lt config.timeThreshold}" class="layui-anim"  data-anim="layui-anim-up" th:text="${system.minRunTime}"></div>

                    <div class="code">最小响应（ms）</div>
                </li>
            </ul>
        </div>

        <div class="layui-tab-item">

            <div class="layui-collapse" lay-filter="test" th:each="runtime : ${list}">
                <div class="layui-colla-item" >
                    <h2 class="layui-colla-title" th:id="${runtime.className}+'.'+${runtime.methodName}">
                        <span th:text="${runtime.className}+'#'+${runtime.methodName}+'&nbsp'"></span>
                        <span th:if="${runtime.avgRunTime ge config.timeThreshold}" class="'layui-badge layui-bg-red" th:text="'平均响应 '+${runtime.avgRunTime}+' 毫秒'"></span>
                        <span th:if="${runtime.avgRunTime lt config.timeThreshold}" class="'layui-badge layui-bg-green" th:text="'平均响应 '+${runtime.avgRunTime}+' 毫秒'"></span>
                    </h2>
                    <div  class="layui-colla-content viewer" style="width: 1500px;height:600px;"> </div>
                </div>
        </div>


    </div>

    <!--联系我-->
    <div class="layui-tab-item">

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend>@zhangchang#1729913829@qq.com</legend>
        </fieldset>
        <script src='https://gitee.com/huoyo/ko-time/widget_preview' async defer></script>
        <div id="osc-gitee-widget-tag"></div>
        <style>
            .osc_pro_color {color: #ffffff !important;}
            .osc_panel_color {background-color: #1e252b !important;}
            .osc_background_color {background-color: #323d47 !important;}
            .osc_border_color {border-color: #455059 !important;}
            .osc_desc_color {color: #d7deea !important;}
            .osc_link_color * {color: #99a0ae !important;}
        </style>
    </div>
</div>
</div>
</div>


<script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/static/jquery.min.js}"></script>
<script th:src="@{/static/echarts.min.js}"></script>
<script th:src="@{/static/config.js}"></script>
<script th:inline="javascript" type="text/javascript">
    $(document).ready(function() {
        var threshold = [[${config.timeThreshold}]];
        var contextPath = [[${#servletContext.contextPath}]]
        layui.use(['element', 'layer'], function () {
            var element = layui.element;
            var layer = layui.layer;

            element.on('collapse(test)', function (data) {
                id = data.title['0'].id
                show(data.content['0'],id)
            });
        });

        function show(element,name) {
            var myChart = echarts.init(element);
            myChart.showLoading();
            $.get(contextPath+'/koTime/getTree?methodName=' + name, function (data) {
                console.log(data)
                myChart.hideLoading();
                echarts.util.each(data.children, function (datum, index) {
                    index % 2 === 0 && (datum.collapsed = true);
                });
                myChart.setOption(option = getOption(data,threshold));
            });
        }

        $('.site-doc-icon').delegate("li",'click', function(data){
        });
    })
</script>

</body>
</html>